package com.xuan.rpc;

import com.xuan.entity.po.UserRoles;
import com.xuan.entity.result.Result;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;

import java.util.List;

@FeignClient(name = "permissionservice", url = "${user.service.url:http://localhost:8082}")
public interface PermissionService {

    @GetMapping("/user/{userId}")
    public Result<String> getUserRoleCode(@PathVariable Long userId);

    // 绑定默认角色（普通用户）
    @GetMapping("/user/bindDefaultRole/{userId}")
    public void bindDefaultRole(@PathVariable Long userId);

    // 超管调用：升级用户为管理员
    @GetMapping("/user/upgradeToAdmin/{userId}")
    public void upgradeToAdmin(@PathVariable Long userId);

    // 超管调用：降级用户为普通角色
    @GetMapping("/user/downgradeToUser/{userId}")
    public void downgradeToUser(@PathVariable Long userId);

    // 管理员调用:查询所有普通用户的id
    @GetMapping("/user/getAllCommonUser")
    public Result<List<Long>> getAllCommonUser();

    // 超管调用: 查询所有用户
    @GetMapping("/user/getAllUser")
    public Result<List<UserRoles>> getAllUser();

}
